<?php
// +----------------------------------------------------------------------
// | Copyright (c) 2020 All rights reserved.
// +----------------------------------------------------------------------
// | User: Simony <1362229026@qq.com>
// | wechat: Shen86579595
// +----------------------------------------------------------------------

namespace app\common\model\report;

use app\common\model\Base;

use think\db;

class ReportUser extends Base
{
    protected $name = 'report_user';


    /**
     * User:Simony
     * Function: 列表
     * @param $condition
     * @param int $page
     * @param string $field
     * @param string $order
     * @return array|\PDOStatement|string|\think\Collection
     * @throws \think\exception\DbException
     * @throws db\exception\DataNotFoundException
     * @throws db\exception\ModelNotFoundException
     */
    public function getReportUserList($condition = [], $page = 0, $field = '*', $order = 'ru.id desc')
    {

        $res = $this->alias('ru')
            ->join('member m', 'ru.member_id=m.id', 'left')
            ->join('member rm', 'ru.report_member_id=rm.id', 'left')
            ->join('report_type rt', 'ru.type_id=rt.id', 'left')
            ->join('content c', 'ru.content_id=c.id', 'left')
            ->where($condition)
            ->field($field)
            ->order($order);


        if ($page) {
            $res = $res->paginate($page, false, ['query' => request()->param()]);
            $this->page_info = $res;
            $res = $res->toArray();
            return $res['data'];
        } else {
            return $res->select()->toArray();
        }
    }

}

?>
